<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../template/AdminTemplate.xhtml">

    <ui:define name="contentInsert">

        <h3>Modify Stakeholder Tier Information</h3>
        <h:form id="tierUpdateForm">

            <br/>
            <p:dataTable value="#{tierManagerBean.allTiers}" var="o"
                         onRowSelectUpdate="tierUpdateForm"
                         selection="#{tierManagerBean.selectedTier}"
                         selectionMode="single"
                         rowSelectListener="#{tierManagerBean.updateFields()}"
                         styleClass="order-table"

                         >

                <p:column>
                    <f:facet name="header">Tier Name</f:facet>
                    <h:outputText id="name" value="#{o.name}" />
                </p:column>

                <p:column>
                    <f:facet name="header">Commission Percentage</f:facet>
                    <h:outputText id="commissionPercent" value="#{o.commissionPercent}"  />
                </p:column>

                <p:column>
                    <f:facet name="header">Subscription Fee</f:facet>
                    <h:outputText value="#{o.feeSubscription}">
                        <f:convertNumber type ="currency" currencySymbol ="$"/>
                    </h:outputText>
                </p:column>

                <p:column>
                    <f:facet name="header">Market Intelligence Fee</f:facet>         
                    <h:outputText value="#{o.feeMarketIntelligence}" >
                        <f:convertNumber type ="currency" currencySymbol ="$"/>
                    </h:outputText>
                </p:column>

                <p:column>
                    <f:facet name="header">Cost Per Click</f:facet>
                    <h:outputText value="#{o.costPerClick}">
                        <f:convertNumber type ="currency" currencySymbol ="$"/>
                    </h:outputText>
                </p:column>   


            </p:dataTable>



            <br/>

            <h3>Click on a row above to edit a tier</h3>


            <p:ajaxStatus style="width:16px;height:16px;">
                <f:facet name="start">
                    <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                </f:facet>
                <f:facet name="complete">
                    <h:outputText value="" />
                </f:facet>
            </p:ajaxStatus>
            <p:messages />   
            <h:panelGrid id="panel" columns="3" >
                <h:outputText value="Tier Name: "  />  <h:outputText value="#{tierManagerBean.name}"/>
                <h:inputHidden value="#{tierManagerBean.name}"/>


                <h:outputText value="Commission Percent: "  /> <h:inputText value="#{tierManagerBean.commissionPercent}"  /><br/>
                <h:outputText value="Subscription Fee: "  /> <h:inputText value="#{tierManagerBean.feeSubscription}"  /><br/>
                <h:outputText value="Market Intelligence Fee: "  /> <h:inputText value="#{tierManagerBean.feeMarketIntelligence}"  /><br/>
                <h:outputText value="Advertising Cost Per Click: "  /> <h:inputText value="#{tierManagerBean.costPerClick}"  /><br/>

                <h:commandButton value="Modify This Tier" 
                                 onclick="if (!confirm('Are you sure you want to modify tier?')) return false"
                                 action="#{tierManagerBean.modifyTier}"
                                 />



                <br/>

            </h:panelGrid>

        </h:form>


    </ui:define>
</ui:composition>

